package validation;

import card.*;

/**
 * An abstract class for building up the common feature and structure of the card type.
 * 
 */
public abstract class Type implements Identifiable{
	protected Cardset lastHand;
	
	/**
	 * Constructor
	 * Set lastHand to null(default)
	 */
	protected Type(){
		lastHand = null;
	}
	
	/**
	 * check if this hand is prior to lasthand
	 * @param Cardset	The hand that want to be compared with the last hand
	 * @return boolean	True if own a higher priority or not exist of last hand, False if own a smaller priority.
	 */
	public boolean lessPriorityThan(Cardset thisHand){
		if(lastHand == null){
			lastHand = thisHand;
			return true;
		} else {
			if(getPriority(thisHand) > getPriority(lastHand)){
				lastHand = thisHand;
				return true;
			} else {
				return false;
			}
		}
	}
	
	/**
	 * To clear the last hand stored inside the object.
	 */
	public abstract void clear();
	
	/**
	 * To identify whether a card set is a specific type.
	 * @param	Cardset The one waiting to be identified
	 * @return	Type Current Class object represent the card type
	 */
	public abstract Type identify(Cardset thisHand);
	
	/**
	 * To get the priority value from a validated card set.
	 * @param	Cardset A identified card set
	 * @return	Integer Priority Value 
	 */
	protected abstract int getPriority(Cardset hand);
	
}
